package cn.com.wantools.service.provider;

import cn.com.wantools.model.exchange.ExchangeQueryConfigInfo;
import cn.com.wantools.model.exchange.UcExchangeQueryConfig;
import cn.com.wantools.service.UcExchangeQueryConfigService;
import io.jboot.aop.annotation.Bean;
import io.jboot.service.JbootServiceBase;

import java.util.List;
import java.util.stream.Collectors;

@Bean
public class UcExchangeQueryConfigServiceProvider extends JbootServiceBase<UcExchangeQueryConfig> implements UcExchangeQueryConfigService {
    @Override
    public List<ExchangeQueryConfigInfo> loadExchangeQueryConfig() {
        List<UcExchangeQueryConfig> list = findAll();
        return list.stream().map(item -> {
            ExchangeQueryConfigInfo exchangeQueryConfigInfo = new ExchangeQueryConfigInfo();
            exchangeQueryConfigInfo.setId(item.getId());
            exchangeQueryConfigInfo.setName(item.getName());
            exchangeQueryConfigInfo.setType(item.getType());
            exchangeQueryConfigInfo.setAppKey(item.getAppKey());
            exchangeQueryConfigInfo.setAppSecret(item.getAppSecret());
            exchangeQueryConfigInfo.setUrlPattern(item.getUrlPattern());
            return exchangeQueryConfigInfo;
        }).collect(Collectors.toList());
    }
}
